/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
 *
 */

import { OhosLogger } from '../utils/log/ohos-logger.js';

const _log = OhosLogger.getLogger('RuntimeOS');

export enum RuntimeTypeEnum {
  UNDEFINED = 0b0000,
  OpenHarmony = 0b0001,
  HARMONY_OS = 0b0010,
}

export namespace RuntimeTypeEnum {
  export function valueOf(runtimeOSStr: string | undefined): RuntimeTypeEnum {
    switch (runtimeOSStr) {
      case undefined:
        return RuntimeTypeEnum.UNDEFINED;
      case 'OpenHarmony':
        return RuntimeTypeEnum.OpenHarmony;
      case 'HarmonyOS':
        return RuntimeTypeEnum.HARMONY_OS;
      default:
        _log.printErrorExit(
          'INVALID_RUNTIME_OS_VALUE',
          [runtimeOSStr]
        );

        // shield ts check
        throw new Error();
    }
  }
}
